package com.bookcode.controller;

import com.bookcode.entity.User;
import com.bookcode.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rest")
public class RegisterController {
    @Autowired
    UserService userService;

    @RequestMapping(value = "/register", method = RequestMethod.POST)
    public String Login(@RequestBody User user) {

        String result = "";
        try {

            userService.save(user);
            result = "成功保存用户信息。";
        } catch (Exception e) {
            result = "保存用户信息失败。";
        } finally {
            return result;
        }


    }

}

